package com.opener.common.code.assistant.gen;

public class ServiceGenerator extends DaoGenerator{

    public ServiceGenerator(Ctx ctx, Ctx.MvcClass mvcClass) {
        super(ctx, mvcClass);
    }



    public String createInsertFunc(){
        Ctx.MvcClass modelCls = getCtx().getMvcClass("model");
        StringBuffer sb = new StringBuffer();
        sb.append("\tInteger add("+modelCls.getClassName()+" "+Utils.lowerFistAlpha(modelCls.getClassName())+");\n");
        return sb.toString();
    }
    public String createUpdateFunc(){
        Ctx.MvcClass modelCls = getCtx().getMvcClass("model");
        StringBuffer sb = new StringBuffer();
        sb.append("\tboolean update("+modelCls.getClassName()+" "+Utils.lowerFistAlpha(modelCls.getClassName())+");\n");
        return sb.toString();
    }
    public String createGetFunc(){
        Ctx.MvcClass modelCls = getCtx().getMvcClass("model");
        StringBuffer sb = new StringBuffer();
        sb.append("\t"+modelCls.getClassName()+" get(Integer id);\n");
        return sb.toString();
    }
    public String createSearchFunc(){
        Ctx.MvcClass modelCls = getCtx().getMvcClass("model");
        Ctx.MvcClass searchArgsCls = getCtx().getMvcClass("search");
        StringBuffer sb = new StringBuffer();
        sb.append("\tList<"+modelCls.getClassName()+"> search("+searchArgsCls.getClassName()+" args);\n");
        return sb.toString();
    }

    public String createSearchCountFunc(){
        Ctx.MvcClass modelCls = getCtx().getMvcClass("model");
        Ctx.MvcClass searchArgsCls = getCtx().getMvcClass("search");
        StringBuffer sb = new StringBuffer();
        sb.append("\tInteger getSearchCount("+searchArgsCls.getClassName()+" args);\n");
        return sb.toString();
    }
    public String createImportAnnotation(){
        return null;
    }
}
